﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;

namespace PlutoStudio.Net.Processors.Attributes
{
    [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    [MetadataAttribute]
    public class ProcessorAttribute : ExportAttribute
    {
                //  http://go.microsoft.com/fwlink/?LinkId=85236
        readonly string  code;

        // This is a positional argument
        public ProcessorAttribute(string code)
            :base(typeof(IMessageProcessor))
        {
            this.code = code;
            Catalog = "Processor";
        }

        public string Code
        {
            get { return code; }
        }

        public string Catalog { get; set; }

        public override bool Match(object obj)
        {
            var other = obj as ProcessorAttribute;
            if (other==null)
            {
                return false;
            }
            return code == other.Code;
        }
    }
}
